﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using Microsoft.Surface;
using Microsoft.Surface.Presentation;
using Microsoft.Surface.Presentation.Controls;
using Microsoft.Surface.Presentation.Input;

namespace eGrid_App
{
    /// <summary>
    /// Interaction logic for UserControl1.xaml
    /// </summary>
    public partial class ExitDialog : UserControl
    {
        private My_Application mainApp;
        private string _name;

        public ExitDialog(My_Application app, string name)
        {
            mainApp = app;
            
            InitializeComponent();        
        }


        
        /// <summary>
        /// Closes the application when the user confirms
        /// to exit.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ConfirmExitButton_Click(object sender, RoutedEventArgs e)
        {
            mainApp.getMainWindow().Close();
        }

        /// <summary>
        /// The user cancels exit.  The exit confirmation dialog
        /// disappears and the related corner function menu button
        /// restarts the timer to hide.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CancelExitButton_Click(object sender, RoutedEventArgs e)
        {
            this.Visibility = Visibility.Hidden;

            switch (this.Name)
            {
                case "ExitDialogUpperLeft":
                    mainApp.FunctionMenuUpperLeft.startTimer();
                    break;
                case "ExitDialogUpperRight":
                    mainApp.FunctionMenuUpperRight.startTimer();
                    break;
                case "ExitDialogBottomLeft":
                    mainApp.FunctionMenuBottomLeft.startTimer();
                    break;
                case "ExitDialogBottomRight":
                    mainApp.FunctionMenuBottomRight.startTimer();
                    break;
            }
        }
    }
}
